import Vue from 'vue'
import Vuex from 'vuex'
import * as types from './mutation_types'
console.log(types)
console.log(types.CHANGE_PRICE)
Vue.use(Vuex)
export default new Vuex.Store({
	state:{
		count: 1,
		city: '香蕉',
		price:''
	},
	actions:{
		// changeFruit(context,fruit){
  //         context.commit('changeFruit',fruit)
		// }
		changeFruit({commit},fruit){ //es6 对象的解构赋值
			commit('changeFruit',fruit)
		},
		changePrice({commit},fruit){
			console.log(fruit)
			commit(types.CHANGE_PRICE,fruit)
		}
	},
	mutations:{
		changeFruit(state,fruit){
          state.city = fruit.name
		},
		[types.CHANGE_PRICE](state,fruit){
			state.price = fruit.price++
		}
	}
})